package com.ruoyi;



import com.binyuan.move.novelweb.ScreenRecorderManager;
import com.binyuan.move.thried.DayStartThread;
import com.binyuan.move.thried.DeleteFileThread;
import com.binyuan.move.thried.MouseMovementThread;
import com.binyuan.move.thried.MouseMovementThreadStarter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

/**
 * 启动程序
 * 
 * @author ruoyi
 */
@MapperScan(value = {"com.binyuan.*.mapper"})
@ComponentScan(value = {"com.binyuan.*","com.ruoyi.*"})
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
 public class RuoYiApplication
{
    public static void main(String[] args) throws InterruptedException {
        ScreenRecorderManager screenRecorderManager = new ScreenRecorderManager();
        MouseMovementThread thread =  new MouseMovementThread();

//        // 注册关闭钩子
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            // 在程序关闭时执行的操作
            System.out.println("Shutting down...");
            if (thread.getVideoRecord() != null)
                thread.stopMove("[关闭程序]");

        }));
        SpringApplication.run(RuoYiApplication.class, args);
        //启动线程
        MouseMovementThreadStarter starter = new MouseMovementThreadStarter();
        starter.init(thread);
        //启动删除文件线程
        new DeleteFileThread().start();
        //启动重置线程
        new DayStartThread(thread).start();
    }
}
